<script lang="ts" setup>
import { useRouter } from 'vue-router'
import { wantStore } from '../../stores/want'

const router = useRouter();
const { wList } = defineProps(['wList'])
const wantPinias = wantStore()

const goMovieDetail = (mid:string) => {
    router.push({
        name:'movieDetail',
        params: {
            id: mid, 
        }
    })
}

const delWantBtn = (mid:string) => {
    wantPinias.delWantList(mid)
}
</script>

<template>
    <van-swipe-cell>
        <div class="want-movies-item" @click="goMovieDetail(wList.id)">
            <img :src="wList.img" alt="">
            <div class="item-con">
                <div class="item-nm">{{ wList.nm }}</div>
                <div class="item-want-num">
                    <span>{{ wList.wantNum }}</span>人想看
                </div>
                <div>
                    主演：{{ wList.actor }}
                </div>
                <div>{{ wList.date }}</div>
            </div>
            <div class="buy-btn-box">
                <div class="buy-btn">购票</div>
            </div>
        </div>
        <template #right>
            <van-button square text="删除" type="danger" class="delete-button" @click="delWantBtn(wList.id)"/>
        </template>
    </van-swipe-cell>
</template>

<style lang="scss" scoped>
.want-movies-item{
    width: 100vw;
    padding: 0 4vw;
    box-sizing: border-box;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 4vw 0;

    img{
        width: 18vw;
        height: 24vw;
        border-radius: 1.5vw;
    }
    .item-con{
        color: #666;
        font-size: 14px;
        width: 54vw;
        height: 24vw;
        display: flex;
        flex-wrap: wrap;
        align-content: space-around;

        div{
            width: 54vw;
            white-space: nowrap;
            text-overflow: ellipsis;
            overflow: hidden;
        }
        .item-nm{
            color: #000;
            font-size: 18px;
            font-weight: bold;
        }
        .item-want-num{

            span{
                color: #f6b114;
                font-size: 15px;
                font-weight: bold;
            }
        }
    }
    .buy-btn-box{
        width: 15vw;
        
        .buy-btn{
            color: #fff;
            font-size: 12px;
            width: 15vw;
            height: 7vw;
            line-height: 7vw;
            text-align: center;
            border-radius: 4vw;
            background-color: #ee3e33;
        }
    }
}
.delete-button{
    height: 24vw;
}
</style>